package com.hpin.mlxteacher.child;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hpin.mlxteacher.R;
import com.hpin.mlxteacher.base.BaseActivity;
import com.hpin.mlxteacher.bean.ChildResult;
//import com.umeng.analytics.MobclickAgent;

/**
 * 孩子手表详情页面
 * Created by Aaron on 15/7/29.
 */
public class WatchDetailActivity extends BaseActivity {

    private TextView tv_name;
//    private TextView tv_invite_code;
    private TextView tv_phone;
    private TextView tv_electricity;
    private TextView tv_signal;
    private TextView tv_adress;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_watch_detail);

        initWidget();

        setData();
    }

    private void setData() {

        ChildResult.childlist child = (ChildResult.childlist) getIntent().getSerializableExtra("child");

        if (child != null) {
            tv_name.setText(child.name);

            if (child.device!=null) {
                tv_adress.setText(child.device.location);
                tv_electricity.setText(child.device.battery + "%");
                tv_phone.setText(child.device.phoneNum);
                tv_signal.setText(child.device.gsm + "%");
            }


//            tv_invite_code.setText(child.inviteKey);
        }
    }

    private void initWidget() {

        ImageView iv_left = (ImageView) findViewById(R.id.iv_left);
        TextView tv_title = (TextView) findViewById(R.id.tv_title);

        tv_title.setText(getResources().getString(R.string.watch_detail));

        iv_left.setOnClickListener(this);

        tv_name = (TextView) findViewById(R.id.tv_name);
//        tv_invite_code = (TextView) findViewById(R.id.tv_invite_code);
        tv_phone = (TextView) findViewById(R.id.tv_phone);
        tv_electricity = (TextView) findViewById(R.id.tv_elect);
        tv_signal = (TextView) findViewById(R.id.tv_signal);
        tv_adress = (TextView) findViewById(R.id.tv_adress);

    }

    @Override
    public void widgetClick(View v) {
        switch (v.getId()) {

            case R.id.iv_left:

                finish();

                break;

        }
    }

//    public void onResume() {
//        super.onResume();
//        MobclickAgent.onResume(this);       //统计时长
//    }
//
//    public void onPause() {
//        super.onPause();
//        MobclickAgent.onPause(this);
//    }
}
